Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting on phase 1 misc beacon changes #1323

Merged
merged 47 commits into from
Sep 2, 2019
Merged

Starting on phase 1 misc beacon changes #1323

merged 47 commits into from
Sep 2, 2019

Conversation

vbuterin
Copy link
Contributor

No description provided.

@hwwhww hwwhww added the phase1 label Jul 30, 2019
Copy link
Contributor

@CarlBeek CarlBeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djrtwo, All @inserts look good to me. (I also tested it with the spec builder and it works as expected too.)

Other comments are minor changes mostly related to whitespace.

specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
@hwwhww hwwhww force-pushed the vbuterin-patch-13 branch from 2329171 to c5acddc Compare August 11, 2019 15:20
Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changelogs

specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Show resolved Hide resolved
hwwhww and others added 4 commits August 12, 2019 00:40
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
specs/core/1_beacon-chain-misc.md Outdated Show resolved Hide resolved
"""
Given a state and a list of validator indices, outputs the CompactCommittee representing them.
"""
validators = [state.validators[i] for i in committee]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
validators = [state.validators[i] for i in committee]
assert len(committee) <= MAX_VALIDATORS_PER_COMMITTEE
validators = [state.validators[i] for i in committee]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? This function could theoretically be used for different kinds of committees; doesn't seem wise to put a maximum designed around a specific type of committee.

Copy link
Contributor

@hwwhww hwwhww Aug 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a safety check since the size of CompactCommittee elements are set to maximum MAX_VALIDATORS_PER_COMMITTEE:

class CompactCommittee(Container):
    pubkeys: List[BLSPubkey, MAX_VALIDATORS_PER_COMMITTEE]
    compact_validators: List[uint64, MAX_VALIDATORS_PER_COMMITTEE]

It leads to one more implicit config validity condition of that MAX_VALIDATORS_PER_COMMITTEE >= TARGET_PERSISTENT_COMMITTEE_SIZE. (p.s. #407)

If we want to make this function could be used for different kinds of committees, how about refactoring this function into:

def pack_committee(state: BeaconState, committee: Sequence[ValidatorIndex]) -> Tuple[Sequence[BLSPubkey], Sequence[int]]:
    validators = [state.validators[i] for i in committee]
    compact_validators = [
        pack_compact_validator(i, v.slashed, v.effective_balance // EFFECTIVE_BALANCE_INCREMENT)
        for i, v in zip(committee, validators)
    ]
    pubkeys = [v.pubkey for v in validators]
    return pubkeys, compact_validators


def committee_to_compact_committee(state: BeaconState, committee: Sequence[ValidatorIndex]) -> CompactCommittee:
    assert len(committee) <= MAX_VALIDATORS_PER_COMMITTEE
    pubkeys, compact_validators = pack_committee(state, committee)
    return CompactCommittee(pubkeys=pubkeys, compact_validators=compact_validators)

```python
class CompactCommittee(Container):
pubkeys: List[BLSPubkey, MAX_VALIDATORS_PER_COMMITTEE]
compact_validators: List[uint64, MAX_VALIDATORS_PER_COMMITTEE]
Copy link
Contributor

@hwwhww hwwhww Aug 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding a custom type CompactValidator: uint64?

Edit: just realized that CompactValidator and unpack_compact_validator are defined in sync_protocol.md. I'd say:

  1. Remove unpack_compact_validator from 1_beacon-chain-misc.md since it's not used here.
  2. Move CompactValidator definition to 1_beacon-chain-misc.md.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unpack_compact_validator from 1_beacon-chain-misc.md since it's not used here.

Where would it be put though? In the light client file that actually uses it? I can see how that's theoretically better in one way, but it has a big disadvantage, which is that pack and unpack are no longer beside each other. So I'd still favor putting both in the same file, to make it easier for readers to see that they are inverses.

vbuterin and others added 8 commits August 26, 2019 10:09
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
@djrtwo
Copy link
Contributor

djrtwo commented Aug 28, 2019

@vbuterin Is this ready for merge?

@vbuterin
Copy link
Contributor Author

vbuterin commented Sep 1, 2019

@vbuterin Is this ready for merge?

I'd say so. My preference is generally to merge earlier for specs that are still in-progress; it makes it easier to propose further changes.

Justin's upcoming PR may force a change to the internals of receipt processing but it won't be large.

@JustinDrake
Copy link
Contributor

Justin's upcoming PR

The PR is ready for review :) #1383

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving a green light in case it's blocking #1383 review. (receipts)

class ShardReceiptProof(Container):
shard: Shard
proof: List[Hash, PLACEHOLDER]
receipt: List[ShardReceiptDelta, PLACEHOLDER]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like ShardReceiptDelta is going away in #1383. Should we define the ShardReceiptDelta container here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to merge this and handle the conflict after reviewing #1383. Thanks for pointing this out :)

@djrtwo djrtwo merged commit 1449697 into dev Sep 2, 2019
@djrtwo djrtwo deleted the vbuterin-patch-13 branch September 2, 2019 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants